package com.kitty.game.bag.service.giftHandler;


import com.kitty.common.utils.SpringUtils;
import com.kitty.game.attribute.AttrService;

import com.kitty.game.bag.message.RespIconCartoon;
import com.kitty.game.bag.model.GiftBagData;
import com.kitty.game.base.service.BagService;

import com.kitty.game.equip.model.*;
import com.kitty.game.equip.service.EquipService;

import com.kitty.game.hunqiao.HunQiaoService;
import com.kitty.game.hunqiao.enums.FieldsEnum;
import com.kitty.game.hunqiao.model.HunQiaoField;
import com.kitty.game.npc.service.NewNpcService;
import com.kitty.game.onlinemall.service.MallService;
import com.kitty.game.role.model.Role;

import com.kitty.mina.message.MessagePusher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


/**
 * 开启礼包得到 自定义/随机 首饰奖励
 */
@Component
public class HunQiaoGiftHandler extends GiftHandler {
    @Autowired
    AttrService attrService;
    @Autowired
    BagService bagService;
    @Autowired
    MallService mallService;

    @Override
    public void getReward(Role role, GiftBagData giftBagData) {
        //开启首饰礼包，弹出NPC 选择力法体敏装备
        String content = "魂窍礼包。[获得力魂窍/hunqiao_li][获得法魂窍/hunqiao_fa][获得体魂窍/hunqiao_ti][获得敏魂窍/hunqiao_min]";
        SpringUtils.getBean(NewNpcService.class).requestNpcContent(role, 15025,content);
//        for (int i = 0; i < giftBagData.getCount(); i ++) {
//            short pos = bagService.getPos(role, false);
//            if (pos <= 0) {
//                return;
//            }
//            this.getJewelry(role, giftBagData, pos);
//        }
    }

    public void sendReward(Role role, String msg) {
        RoleEquip roleEquip = SpringUtils.getBean(EquipService.class).getRoleEquipByName(role, "金色魂窍礼包");
        //删除叠加物品
        if (SpringUtils.getBean(EquipService.class).delEquipNum(role, roleEquip, 1) <= 0) {
            return;
        }
        int type=0;
        switch (msg){
            case "hunqiao_li":
                type=1;
                break;
            case "hunqiao_fa":
                type=2;
                break;
            case "hunqiao_ti":
                type=3;
                break;
            case "hunqiao_min":
                type=4;
                break;
        }
        List<HunQiaoField> hunQiFields = new ArrayList<>();
        if(type == 1){
            //构造参数
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(0+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(1+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(2+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
        }else if(type == 2){
//构造参数
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(0+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(1+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(2+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
        }else if(type == 3){
//构造参数
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(0+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(1+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(2+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
        }else if(type == 4){
//构造参数
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(0+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(1+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
            {
                HunQiaoField hunQiaoField =  new HunQiaoField((byte)(2+2), FieldsEnum.F220.fieldId,(short)100);
                hunQiFields.add(hunQiaoField);
            }
        }
        SpringUtils.getBean(HunQiaoService.class).addHunQiao(role,hunQiFields);
    }



}
